<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增单据')" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-doc-add">
			<div class="form-group">
				<label class="col-sm-2 control-label">日期：</label>
				<div class="col-sm-10 input-group date">
					<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
					<input type="text" class="form-control" id="datetimepicker-demo-2" name="docDate" placeholder="请输入日期">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">时间段：</label>
				<div class="col-sm-10">
					<div class="radio-box" th:each="dict : ${@dict.getType('trans_time')}">
						<input type="radio" th:id="${dict.dictCode}" name="docTime" th:value="${dict.dictValue}" th:checked="${dict.default}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label is-required">供应商：</label>
				<div class="col-sm-10">
					<select id="supplier" class="form-control select2-multiple" multiple>
						<option th:each="supp:${suppliers}" th:value="${supp.sId}" th:text="${supp.name}" ></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label is-required">车牌：</label>
				<div class="col-sm-10">
					<input id="licensePlate" name="licensePlate" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label is-required">司机：</label>
				<div class="col-sm-10">
					<input id="driver" name="driver" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label is-required">电话号码：</label>
				<div class="col-sm-10">
					<input id="phone" name="phone" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label is-required">商品：</label>
				<div class="col-sm-10">
					<input id="goods" name="goods" class="form-control" type="text" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label is-required">数量：</label>
				<div class="col-sm-10">
					<input id="quantity" name="quantity" class="form-control" type="text" >
				</div>
			</div>
		</form>
	</div>
    <th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
	<th:block th:include="include :: select2-js" />
    <script type="text/javascript">
        var prefix = ctx + "trans/doc";
		$(function(){
			$("#datetimepicker-demo-2").datetimepicker({
				format: "yyyy-mm-dd",
				minView: "month",
				autoclose: true
			});

			$('#supplier').select2({
				placeholder: "请选择岗位",
				allowClear: true
			});
		});
		$("#form-supplier-add").validate({
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				var data = $("#form-doc-add").serializeArray();
				var supplier = $.form.selectSelects("supplier");
				data.push({"name": "supplier", "value": supplier});
				$.operate.save(prefix + "/add", data);
	        }
	    }
	</script>
</body>
</html>
